home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / PartMaker 4.3 / Start.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-12  |  4.3 KB  |  150 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        Start.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1989-1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19.  
  20.  
  21. /*****************************************************************************/
  22.  
  23.  
  24.  
  25. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  26. #include "App.defs.h"        /* Get various application definitions.            */
  27. #include "App.protos.h"        /* Get the prototypes for application.            */
  28.  
  29. #ifndef __TEXTSERVICES__
  30. #include <TextServices.h>
  31. #endif
  32.  
  33. #ifndef __TOOLUTILS__
  34. #include <ToolUtils.h>
  35. #endif
  36.  
  37. #ifndef __ATGLIB__
  38. #include "ATGLIB.h"
  39. #endif
  40.  
  41.  
  42.  
  43. /*****************************************************************************/
  44.  
  45. /* In this file, we first set some global values.  This allows the application and
  46. ** DTS.Lib..framework to "know" what is expected for certain actions.
  47. **
  48. ** Note that the management of globals has changed in AppsToGo version 8.0
  49. ** This is so shared library support could be added to AppsToGo.  The globals
  50. ** that used to be defined in the application have been moved into the library.
  51. ** This is because application can see library globals, but not visa-versa.
  52. ** Of course, this means that the globals are set to some reasonable initial
  53. ** value in the framework, and now need to be modified via code in the application.
  54. ** The code in DoOpenApplication does this.
  55. **
  56. ** DoOpenApplication used to be in the file Window.c.  Now that this new functionality
  57. ** has been added, it makes more sense that this function be moved into Start.c. */
  58.  
  59. extern void     _DataInit();
  60.  
  61. /**/
  62.  
  63. extern TreeObjProcPtr    gTreeObjMethods[], *gpTreeObjMethods;
  64. extern long                gMinTreeObjSize[], *gpMinTreeObjSize;
  65.  
  66. extern short            gMinVersion, gMaxVersion;
  67. extern short            gQuickBalloons;
  68.  
  69.  
  70.  
  71. /*****************************************************************************/
  72.  
  73.  
  74.  
  75. /* •• You don't call this.  DTS.Lib..framework does at open-application time. •• */
  76.  
  77.  
  78. OSErr    DoOpenApplication(void)
  79. {
  80.     gMinVersion = kMinVersion;                    /* Minimum document version app can support. */
  81.     gMaxVersion = kMaxVersion;                    /* Maximum document version app can support. */
  82.  
  83.     gpTreeObjMethods = gTreeObjMethods;            /* Let framework know about File.c object defs. */
  84.     gpMinTreeObjSize = gMinTreeObjSize;
  85.  
  86.     gQuickBalloons = (shiftKey | controlKey);
  87.  
  88.     return(noErr);
  89. }
  90.  
  91.  
  92.  
  93. /*****************************************************************************/
  94. /*****************************************************************************/
  95.  
  96. #ifdef applec
  97. #pragma segment Main
  98. #endif
  99.  
  100. /*****************************************************************************/
  101. /*****************************************************************************/
  102.  
  103.  
  104.  
  105. void    main(void)
  106. {
  107.  
  108. #ifdef applec
  109.     UnloadSeg((Ptr)_DataInit);        /* Note that _DataInit can't be in Main! */
  110. #endif
  111.  
  112.     SetApplLimit(GetApplLimit() - 16384);
  113.         /* This decreases the application heap by 16k, which in turn
  114.         ** increases the stack by 16k. */
  115.  
  116.     MaxApplZone();                    /* Expand the heap so code segments load at the top. */
  117.  
  118.     InitATGLIB();
  119.  
  120.     Initialize(32, kMinHeap, kMinSpace, nil, nil);    /* Initialize the program. */
  121.     DoSetResCursor(watchCursor);                    /* Rest of startup may take a while. */
  122.     InitRequiredAppleEvents();
  123.     InitWFMTAppleEvents();
  124.     CLVInitialize();
  125.  
  126.     DoOpenApplication();
  127.     GetWindowFormats();                        /* Get the window definition resource information. */
  128.  
  129. //    ReadPreferences('aprf', gSignature, kPrefFileName);
  130. //    DefaultPreferences();
  131.     OpenRuntimeOnlyAutoNewWindows();
  132.     DoAdjustMenus();
  133.     StartDocuments();                        /* Open (or print) designated documents for 6.0. */
  134.  
  135.     if(CTEUseTSMTE())
  136.         InitTSMAwareApplication();
  137.  
  138.     UnloadSeg((Ptr)Initialize);        /* Initialize can't be in Main! */
  139.     EventLoop();                    /* Call the main event loop. */
  140.  
  141.     if(CTEUseTSMTE())
  142.         CloseTSMAwareApplication();
  143.  
  144. //    WritePreferences();
  145.     ExitToShell();                    /* Quit the application. */
  146. }
  147.  
  148.  
  149.  
  150.